<#import "macros.ftl" as godt>
<html>
	<head>
		<title>${component.name}</title>
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/text.css" />
		<link rel="stylesheet" href="../../css/960.css" />
		<link rel="stylesheet" type="text/css" href="../../css/godt.css" />
	</head>
	<body>
		<div class="container_12">
			<div class="grid_12 border_rounded">
				<h1><strong>${component.name}</strong></h1>			
			</div>
			<div class="clear"></div>
			<div class="grid_12 title">
				<h3><strong>General Properties</strong></h3>
			</div>
			<div class="clear"></div>
			<div class="grid_6 central">
				Type: <em>${component.type}</em><br/>
				Loader: <em>${component.loader}</em><br/>
				Location: <em>${component.location}</em>	
				Reader Name: <em>${component.readerName}</em>			
			</div>
			<div class="grid_6 central">
				Title: <em>${component.title}</em><br/>
				Description: <em>${component.description}</em><br/>
				Author: <em>${component.author}</em><br/>
				Version: <em>${component.version}</em><br/>
				Copyright: <em>${component.copyright}</em>
			</div>
			<#if component.entities?size gt 0>
				<div class="grid_12 title">
					<h2><strong>Entities</strong></h2>
				</div>
				<div class="clear"></div>
				
				<#list component.entities as entity>
					<div class="grid_12 title">
						<a name="${entity.entityName?default('')}"></a>
						<h3><strong>${entity.entityName?default('')}</strong></h3>
					</div>
					<div class="grid_12 image">
						<img src="images/${entity.entityName}.png"/>
					</div>
					<div class="clear"></div>					
					<div class="grid_12 description">
						${entity.description?default('')}
					</div>
					<div class="clear"></div>
					<div class="grid_3 lateral">							
						Title: <em>${entity.title}</em><br/>
						Description: <em>${entity.description}</em><br/>
						Author: <em>${entity.author}</em><br/>
						Version: <em>${entity.version}</em><br/>
						Copyright: <em>${entity.copyright}</em>											
					</div>
					<div class="grid_6 central">						
							Table Name:<em>${entity.tableName}</em><br/>
							Package Name:<em>${entity.packageName}</em><br/>
							Dependent On:<em>${entity.dependentOn}</em><br/>
							Sequence Bank Size:<em>${entity.sequenceBankSize}</em>
					</div>
					<div class="grid_3 lateral">							
						<@godt.sign value=entity.enableLock?default('true')/>Enable Lock<br/>
						<@godt.sign value=entity.noAutoStamp?default('true')/>No AutoTimeStamp<br/>
						<@godt.sign value=entity.neverCache?default('true')/>Never Cache<br/>
						<@godt.sign value=entity.autoClearCache?default('true')/>Auto Clear Cache
					</div>
					<div class="clear"></div>
					<#if entity.fields?size gt 0>
						<div class="grid_12 views">
							<table>
								<thead>
									<tr>
										<th colspan="9">Fields</th>
									</tr>
									<tr>
										<th>&nbsp;</th>
										<th>Name</th>
										<th>Column Name</th>
										<th>Type</th>
										<th>Description</th>
										<th>Encrypt</th>
										<th>Enable Audit Log</th>
										<th>Not Null</th>
										<th>Validations</th>
									</tr>
								</thead>
								<tbody>
									<@godt.entityFields entity=entity/>
									<#if entity.extendedEntities?size gt 0>										
										<#list entity.extendedEntities as extend>
											<#if extend.fields?size gt 0>
												<tr>
													<th colspan="9">Defined in: <@godt.link component=extend anchor=extend.entityName text=extend.parent.module /></th>
											    </tr>
											    <@godt.entityFields entity=extend/>
										    </#if>
									    </#list>
									</#if>
								</tbody>
							</table>
						</div>
						<div class="clear"></div>
					</#if>
					<#if entity.primaryKeys?size gt 0>
						<div class="grid_12 lateral">
							<table>
								<tr>
									<th colspan="5">Primary Keys</th>
								</tr>
								<#list entity.primaryKeys?chunk(5) as chunk>
									<tr>
										<#list chunk as key>
											<td>${key}</td>
										</#list>
									</tr>
								</#list>
							</table>
						</div>
						<div class="clear"></div>
					</#if>
					<#if entity.indexes?size gt 0>
						<div class="grid_12 central">
							<table>
								<thead>
									<tr>
										<th colspan="4">Indexes</th>
									</tr>
									<tr>
										<th>Name</th>
										<th>Description</th>
										<th>Fields</th>
										<th>Unique</th>
									</tr>
								</thead>
								<tbody>
									<#list entity.indexes as index>
										<tr>
											<td>${index.name}</td>
											<td>${index.description}</td>
											<td>
												<ul>
													<#list index.fields as field>
														<#assign myLink=entity.entityName+"_"+field>
														<li><@godt.link component=entity anchor=myLink text=field /></li>
													</#list>
												</ul>
											</td>
											<td><@godt.sign value=index.unique?default('false')/></td>
										</tr>										
									</#list>
									<#if entity.extendedEntities?size gt 0>
											<#list entity.extendedEntities as extend>
												<#if extend.indexes?size gt 0>											
													<tr>
														<th colspan="9">Defined in: <@godt.link component=extend anchor=extend.entityName text=extend.parent.module /></th>
												    </tr>
												    <#list extend.indexes as index>
														<tr>
															<td>${index.name}</td>
															<td>${index.description}</td>
															<td>
																<ul>
																	<#list index.fields as field>
																		<li><@godt.link component=entity anchor=extend.entityName+"_"+field text=field /></li>
																	</#list>
																</ul>
															</td>
															<td><@godt.sign value=index.unique?default('false')/></td>
														</tr> 
													</#list>   
											    </#if>
										    </#list>
										</#if>
								</tbody>
							</table>
						</div>
						<div class="clear"></div>
					</#if>
					<#if entity.relations?size gt 0>
						<div class="grid_12 central">
							<table>
								<thead>
									<tr>
										<th colspan="7">Relations</th>
									</tr>
									<tr>
										<th>Entity</th>
										<th>Type</th>
										<th>FK Name</th>
										<th>Title</th>
										<th>Description</th>
										<th>Field Name</th>
										<th>Related Field Name</th>
									</tr>
								</thead>
								<tbody>
									<#list entity.relations as relation>
										<tr>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.relEntityName}</td>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.type}</td>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.fkName}</td>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.title}</td>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.description}</td>
											<#list relation.keyMaps as key>
												<td>${key.fieldName}</td>
												<td>${key.relFieldName}</td>
												<#if key_has_next>
													</tr><tr>
												</#if>
											</#list>
										</tr>
									</#list>
									<#if entity.extendedEntities?size gt 0>
										<#list entity.extendedEntities as extend>
											<#if extend.relations?size gt 0>											
												<tr>
													<th colspan="9">Defined in: <@godt.link component=extend anchor=extend.entityName text=extend.parent.module /></th>
											    </tr>
											    <#list extend.relations as relation>
													<tr>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.relEntityName}</td>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.type}</td>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.fkName}</td>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.title}</td>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.description}</td>
														<#list relation.keyMaps as key>
															<td>${key.fieldName}</td>
															<td>${key.relFieldName}</td>
															<#if key_has_next>
																</tr><tr>
															</#if>
														</#list>
													</tr> 
												</#list>   
										    </#if>
									    </#list>
									</#if>
								</tbody>
							</table>
						</div>
						<div class="clear"></div>
					</#if>
				</#list>
			</#if>
			<#if component.viewEntities?size gt 0>
				<div class="grid_12 title">
					<h2><strong>View Entities</strong></h2>
				</div>
				<div class="clear"></div>
				<#list component.viewEntities as entity>
					<div class="grid_12 title">
						<a name="${entity.entityName?default('')}"></a>
						<h3><strong>${entity.entityName?default('')}</strong></h3>
					</div>
					<div class="grid_12 image">
						<img src="images/${entity.entityName}.png"/>
					</div>
					<div class="clear"></div>					
					<div class="grid_12 description">
						${entity.description?default('')}
					</div>
					<div class="clear"></div>
					<div class="grid_3 lateral">							
						Title: <em>${entity.title}</em><br/>
						Description: <em>${entity.description}</em><br/>
						Author: <em>${entity.author}</em><br/>
						Version: <em>${entity.version}</em><br/>																	
					</div>
					<div class="grid_6 central">
						Copyright: <em>${entity.copyright}</em><br/>						
						Package Name:<em>${entity.packageName}</em><br/>
						Dependent on:<em>${entity.dependentOn}</em><br/>
						Default Resource Name:<em>${entity.defaultResourceName}</em>
					</div>
					<div class="grid_3 lateral">							
						<@godt.sign value=entity.neverCache?default('true')/>Never Cache<br/>
						<@godt.sign value=entity.autoClearCache?default('true')/>Auto Clear Cache
					</div>
					<div class="clear"></div>	
					<#if entity.memberEntities?size gt 0>
						<div class="grid_12 views">
							<table>
								<thead>
									<tr>
										<th colspan="3">Member Entities</th>
									</tr>
									<tr>
										<th>Entity Name</th>
										<th>Entity Alias</th>
										<th>Description</th>
									</tr>
								</thead>
								<tbody>
									<#list entity.memberEntities as member>
										<tr>
											<td><@godt.link component=member.relatedEntity anchor=member.entityName  /></td>
											<td>${member.entityAlias}</td>
											<td>${member.description}</td>
										</tr>
									</#list>
								</tbody>
							</table>
						</div>
						<div class="clear"></div>
					</#if>		
					<#if entity.aliases?size gt 0>
						<div class="grid_12 central">
							<table>
								<thead>
									<tr>
										<th colspan="10">Aliases</th>
									</tr>
									<tr>
										<th>Alias</th>
										<th>Entity</th>
										<th>Field</th>
										<th>Column alias</th>
										<th>Primary Key</th>
										<th>Group by</th>
										<th>Function</th>
										<th>Description</th>
										<th>Complex Aliases</th>
									</tr>
								</thead>
								<tbody>
									<#list entity.aliases as alias>
										<tr>
											<td>${alias.entityAlias}</td>
											<td><#if alias.relatedEntity?exists>${alias.relatedEntity.entityName}</#if></td>
											<td><#if alias.relatedEntity?exists>
													<@godt.link component=alias.relatedEntity anchor=alias.name  />
												<#else>${alias.name}
											</#if></td>
											<td>${alias.field}</td>
											<td>${alias.colAlias}</td>										
											<td>${alias.groupBy}</td>
											<td>${alias.function}</td>
											<td>${alias.description}</td>
											<td>
												<#if alias.complexAliases?size gt 0>
													<#list alias.complexAliases as complex>
														<@godt.displayComplex complex/>
													</#list>												
												<#else>
													&nbsp;
												</#if>											
											</td>
										</tr>
									</#list>
								</tbody>
							</table>
						</div>
						<div class="clear"></div>
					</#if>
					<#if entity.aliasesall?size gt 0 >
						<div class="grid_12 views">
							<table>
								<thead>
									<tr>
										<th colspan="6">Aliases All</th>
									</tr>
									<tr>
										<th>Alias</th>
										<th>Entity</th>
										<th>Description</th>
										<th>Prefix</th>
										<th>Group By</th>
										<th>Excludes</th>
									</tr>
								</thead>
								<tbody>
									<#list entity.aliasesall as alias>
										<tr>
											<td>${alias.entityAlias}</td>
											<td><#if alias.relatedEntity?exists>${alias.relatedEntity.entityName}</#if></td>
											<td>${alias.description}</td>
											<td>${alias.prefix}</td>
											<td>${alias.groupBy}</td>
											<td>
												<#if alias.excludes?size gt 0>
													<ul>
														<#list alias.excludes as exclude>
															<li>${exclude}</li>
														</#list>
													</ul>
												<#else>
													&nbsp;
												</#if>
											</td>
										</tr>
									</#list>
								</tbody>
							</table>
						</div>
						<div class="clear"></div>
					</#if>
					<#if entity.viewLinks?size gt 0>
						<div class="grid_12 views">
							<table>
								<thead>
									<tr>
										<th colspan="8">View Links</th>
									</tr>
									<tr>
										<th>Entity Alias</th>
										<th>Entity</th>
										<th>Related Entity Alias</th>
										<th>Related Entity</th>
										<th>Description</th>
										<th>Optional</th>
										<th>Field Name</th>
										<th>Related Field Name</th>
									</tr>
								</thead>
								<tbody>
									<#list entity.viewLinks as link>
										<tr>
											<td rowspan="${link.keyMaps?size}">${link.entityAlias}</td>
											<td rowspan="${link.keyMaps?size}"><#if link.relatedEntity?exists>${link.relatedEntity.entityName}</#if></td>
											<td rowspan="${link.keyMaps?size}">${link.relEntityAlias}</td>
											<td rowspan="${link.keyMaps?size}"><#if link.relatedLinkEntity?exists>${link.relatedLinkEntity.entityName}</#if></td>
											<td rowspan="${link.keyMaps?size}">${link.description}</td>
											<td rowspan="${link.keyMaps?size}">${link.relOptional}</td>
											<#list link.keyMaps as key>
												<td>${key.fieldName}</td>
												<td>${key.relFieldName}</td>
												<#if key_has_next>
													</tr><tr>
												</#if>
											</#list>
										</tr>
									</#list>
								</tbody>
							</table>
						</div>
						<div class="clear"></div>
					</#if>
					<#if entity.relations?size gt 0>
						<div class="grid_12 central">
							<table>
								<thead>
									<tr>
										<th colspan="7">Relations</th>
									</tr>
									<tr>
										<th>Entity</th>
										<th>Type</th>
										<th>FK Name</th>
										<th>Title</th>
										<th>Description</th>
										<th>Field Name</th>
										<th>Related Field Name</th>
									</tr>
								</thead>
								<tbody>
									<#list entity.relations as relation>
										<tr>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.relEntityName}</td>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.type}</td>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.fkName}</td>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.title}</td>
											<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.description}</td>
											<#list relation.keyMaps as key>
												<td>${key.fieldName}</td>
												<td>${key.relFieldName}</td>
												<#if key_has_next>
													</tr><tr>
												</#if>
											</#list>
										</tr>
									</#list>
									<#if entity.extendedEntities?size gt 0>
										<#list entity.extendedEntities as extend>
											<#if extend.relations?size gt 0>											
												<tr>
													<th colspan="9">Defined in: <@godt.link component=extend anchor=extend.entityName text=extend.parent.module /></th>
											    </tr>
											    <#list extend.relations as relation>
													<tr>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.relEntityName}</td>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.type}</td>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.fkName}</td>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.title}</td>
														<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.description}</td>
														<#list relation.keyMaps as key>
															<td>${key.fieldName}</td>
															<td>${key.relFieldName}</td>
															<#if key_has_next>
																</tr><tr>
															</#if>
														</#list>
													</tr> 
												</#list>   
										    </#if>
									    </#list>
									</#if>
								</tbody>
							</table>
						</div>
						<div class="clear"></div>
					</#if>
				</#list>				
			</#if>
			<#if component.extendEntities?size gt 0>
				<div class="grid_12 title">
					<h2><strong>Extended Entities</strong></h2>
				</div>
				<div class="clear"></div>
				<#list component.extendEntities as entity>
					<div class="grid_12 title">
						<a name="${entity.entityName?default('')}"></a>
						<h3><strong>${entity.entityName?default('')}</strong></h3>
					</div>
					<div class="grid_12 views">
						<table>
							<thead>
								<tr>
									<th colspan="9">Fields</th>
								</tr>
								<tr>
									<th>&nbsp;</th>
									<th>Name</th>
									<th>Column Name</th>
									<th>Type</th>
									<th>Description</th>
									<th>Encrypt</th>
									<th>Enable Audit Log</th>
									<th>Not Null</th>
									<th>Validations</th>
								</tr>
							</thead>
							<tbody>
								<#if entity.relatedEntity?exists>
									<tr>
										<th colspan="9">Extending model in: <@godt.link component=entity anchor=entity.entityName text=entity.relatedEntity.parent.module /></th>
								    </tr>
							    </#if>
								<@godt.entityFields entity=entity/>								
							</tbody>
						</table>
					</div>	
					<div class="clear"></div>
					<div class="grid_12 central">
						<table>
							<thead>
								<tr>
									<th colspan="7">Relations</th>
								</tr>
								<tr>
									<th>Entity</th>
									<th>Type</th>
									<th>FK Name</th>
									<th>Title</th>
									<th>Description</th>
									<th>Field Name</th>
									<th>Related Field Name</th>
								</tr>
							</thead>
							<tbody>
								<#if entity.relatedEntity?exists>
									<tr>
										<th colspan="7">Extending model in: <@godt.link component=entity anchor=entity.entityName text=entity.relatedEntity.parent.module /></th>
								    </tr>
							    </#if>
								<#list entity.relations as relation>
									<tr>
										<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.relEntityName}</td>
										<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.type}</td>
										<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.fkName}</td>
										<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.title}</td>
										<td rowspan="${relation.keyMaps?size}" valign="middle">${relation.description}</td>
										<#list relation.keyMaps as key>
											<td>${key.fieldName}</td>
											<td>${key.relFieldName}</td>
											<#if key_has_next>
												</tr><tr>
											</#if>
										</#list>
									</tr>
								</#list>								
							</tbody>
						</table>
					</div>
					<div class="clear"></div>	
					<#if entity.indexes?size gt 0>
						<div class="grid_12 central">
							<table>
								<thead>
									<tr>
										<th colspan="4">Indexes</th>
									</tr>
									<tr>
										<th>Name</th>
										<th>Description</th>
										<th>Fields</th>
										<th>Unique</th>
									</tr>
								</thead>
								<tbody>
									<#if entity.relatedEntity?exists>
									<tr>
										<th colspan="4">Extending model in: <@godt.link component=entity anchor=entity.entityName text=entity.relatedEntity.parent.module /></th>
								    </tr>
								    </#if>
									<#list entity.indexes as index>
										<tr>
											<td>${index.name}</td>
											<td>${index.description}</td>
											<td>
												<ul>
													<#list index.fields as field>
														<#assign myLink=entity.entityName+"_"+field>
														<li><@godt.link component=entity anchor=myLink text=field /></li>
													</#list>
												</ul>
											</td>
											<td><@godt.sign value=index.unique?default('false')/></td>
										</tr>										
									</#list>							
								</tbody>
							</table>
						</div>
						<div class="clear"></div>
					</#if>	
				</#list>				
			</#if>
		</div>	
	</body>
</html>